package com.example.homework.homework05;

// 1.定义线程任务类PrinterCharTask，实现Runnable接口
public class PrinterCharTask implements Runnable {
    private char ch = 'A';

    public PrinterCharTask(char ch) {
        this.ch = ch;
    }

    @Override
    public void run() {
        while (true) {
            synchronized (this) {
                // 如果ch大于Z，则退出循环
                if (ch >= 'Z') {
                    break;
                }
                // 输出ch
                System.out.print(ch + " ");
                ch++;
            }
        }
    }
}
